package org.example.c1;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.TimeUnit;

/**
 * @author liu-rui
 * @date 2020/5/27 下午4:59
 * @description 　观察线程的状态变化
 * @since
 */
@Slf4j
public class Demo12 {
    public static void main(String[] args) throws InterruptedException {

        new Thread(() -> {
            synchronized (Demo12.class) {
                try {
                    TimeUnit.SECONDS.sleep(5);
                } catch (InterruptedException e) {
                }
                Demo12.class.notify();
            }
        }, "assist").start();

        final Thread t1 = new Thread(() -> {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
            }
            synchronized (Demo12.class) {

            }
        }, "t1");


        log.info( "{}" ,  t1.isAlive());
        t1.start();
        TimeUnit.SECONDS.sleep(2);
        log.info("{}" , t1.getState());
        log.info( "{}" ,  t1.isAlive());
    }
}
